<?php

namespace app\jok\controller;

use app\jok\logic\systemAdminLogic;
use think\Controller;
use think\Request;
use think\Db;

class Admin extends Controller
{
    public function index()
    {
        $get = Request::instance()->get();
        $result = (new systemAdminLogic)->adminGetList($get);
        return json($result);
    }
    public function addEdit()
    {
        $post = Request::instance()->post();
        $result = (new systemAdminLogic)->adminAddEdit($post);
        return json($result);
    }
    public function getDetail()
    {
        $get = Request::instance()->get();
        $result = (new systemAdminLogic)->adminDataDetail($get);
        return json($result);
    }
    public function setStatus()
    {
        $post = Request::instance()->post();
        $res = Db::name('system_admin')->where('id', $post['id'])->setField('status', $post['status']);
        if ($res) {
            $result = ['code' => 1, 'msg' => '设置成功'];
        } else {
            $result = ['code' => 0, 'msg' => '设置失败'];
        }
        return json($result);
    }
    public function roleIndex()
    {
        $get = Request::instance()->get();
        $result = (new systemAdminLogic)->roleGetList($get);
        return json($result);
    }
    public function roleAddEdit()
    {
        $post = Request::instance()->post();
        $result = (new systemAdminLogic)->roleAddEdit($post);
        return json($result);
    }
    public function roleGetDetail()
    {
        $get = Request::instance()->get();
        $result = (new systemAdminLogic)->roleDataDetail($get);
        return json($result);
    }
}
